﻿@using PopForums.Controllers;
@using PopForums.Extensions;
@model ICollection<Microsoft.Owin.Security.AuthenticationDescription>
@{
    ViewBag.Title = PopForums.Resources.Login;
    Layout = "~/Areas/PopForums/Views/Shared/PopForumsMaster.mobile.cshtml";
}

@section HeaderContent
{
	<script language="javascript" type="text/javascript">
		$(function () {
			$("#LoginButton").click(PopForums.processLogin);
			$("#EmailLogin,#PasswordLogin").keydown(function (e) { if (e.keyCode == 13) PopForums.processLogin(); });
		});
	</script>
}

@if (this.GetUserFromViewData() == null)
{
	<p id="LoginResult" class="warning"></p>
	
	<label for="EmailLogin" class="pf-label">@PopForums.Resources.Email</label>
	<input id="EmailLogin" name="EmailLogin" class="pf-text" type="text" />
	
	<label for="PasswordLogin" class="pf-label">@PopForums.Resources.Password</label>
	<input id="PasswordLogin" name="PasswordLogin" class="pf-text" type="password" />
	
	<p>@Html.CheckBox("PersistCookie", new { @class = "pf-check"}) <label for="PersistCookie" class="pf-label">@PopForums.Resources.RememberMe</label></p>
	
	<input id="LoginButton" type="button" value="@PopForums.Resources.Login" class="pf-button" />

	<p>@Html.ActionLink(PopForums.Resources.ForgotPasswordQuestion, "Forgot", AccountController.Name)</p>

	@Html.Hidden("Referrer", (object)ViewBag.Referrer)
	
	if (Model.Count > 0)
	{
		using (Html.BeginForm("ExternalLogin", "Authorization", new { ReturnUrl = ViewBag.Referrer }))
		{
			@Html.AntiForgeryToken()
			<h2>@PopForums.Resources.ExternalLogins</h2>
			<p>
				@foreach (var authenticationDescription in Model)
				{
					<button type="submit" id="@authenticationDescription.AuthenticationType" name="provider" value="@authenticationDescription.AuthenticationType" class="pf-button">@authenticationDescription.AuthenticationType</button>
				}
			</p>
		}
	}
}
else
{
	<p>@PopForums.Resources.LoginAlready</p>
}